<template>
  <div class="container">
<button @click="goback" style="float:left">goback</button>
    <div class="row" style="padding-top: 10px;">
      <div class="col-md-12">
        <div class="data_list">
          <div class="data_list_title">
            <img src="./image/detail.png" />
            邮件详细信息
          </div>

          <div class="data_details">
            <div class="data_row">
              <strong style="float:left"></strong>
              <strong class="CSS5-left">收件人 :{{ToText(emlIndex.recipientAddress)}}</strong>
              <p style="float:right">emlMd5Code:{{ToText(emlIndex.emlMd5Code)}}</p>
            </div>
            <div class="data_row">
              <strong>邮件主题 ：</strong>
              <span>{{ToText(emlIndex.subject)}}</span>
            </div>
            <div class="data_row">
              <strong>发件人 ：</strong>
              <span>{{ToText(emlIndex.senderName)}}</span>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <strong>发件日期 ：</strong>
              <span>{{ToText(emlIndex.senderDate)}}(UTC-08:00 温哥华、洛杉玑、西雅图时间)</span>
            </div>
            <div class="data_row">
              <strong style="float:left">邮件内容：</strong>
              <span v-html="emlIndex.emlContent"></span>
            </div>

            <div class="data_row" v-if="emlIndex.attachmentLocation!=null">
              <el-link
                :href="'/api/EmlSearchController/attachmentDownload/' + encodeURIComponent(emlIndex.attachmentLocation)"
                :underline="true"
                style="margin-left:15px"
              >
                <el-button size="mini" type="warning" v-if="emlIndex.attachmentType!='无'">请在此处下载附件</el-button>
              </el-link>
              <br>
              <strong>附件类型 :{{ToText(emlIndex.attachmentType)}}</strong>
              <br>
              <strong>附件内容 :{{ToText(emlIndex.attachmentContent)}}</strong>
            </div>
            <div class="data_row">
              <strong>免责申明：</strong>
              <br />
              <p>
                [
                <strong>{{ToText(emlIndex.subject)}}</strong> ] 由发件人
                [<strong>{{ToText(emlIndex.senderName)}}</strong>] 于
                [<strong>{{ToText(emlIndex.senderDate)}}(UTC-08:00 温哥华、洛杉玑、西雅图时间)</strong>] 发送给
                <strong>{{ToText(emlIndex.recipientAddress)}}</strong>。
                此邮件本人从邮件客户端或三方公司抓取解析，取自本人Elastic服务器只作交流和学习使用。
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>


<script>
import axios from "axios";
export default {
  data() {
    return {
      emlIndex: {},
      downloadVisible: "false"
    };
  },
  watch: {
    $route(to, from) {
      console.log(to.path); //当前页面path即/showuser
      this.init();
    }
  },
  mounted() {
    this.init();
    // for (const key in this.emlIndex) {
    //   if (this.emlIndex.hasOwnProperty(key)) {
    //     const element = this.emlIndex[key];
    //     console.log(element)

    //   }
    // }
  },
  methods: {
     goback(){
        this.$router.go(-1);//返回上一层
    },
    init() {
      this.emlIndex = this.$route.query.emlIndex;
      console.log("this.emlIndex");
      console.log(this.emlIndex);
    },
    ToText(HTML) {
      if (HTML != null) {
        var input = HTML;
        return input
          .replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi, "")
          .replace(/<[^>]+?>/g, "")
          .replace(/\s+/g, " ")
          .replace(/ /g, " ")
          .replace(/>/g, " ");
      }
    },
    downLoadAttachment(location) {
      //   this.$refs.link.onclick = function(){
      //     alert("跳不动呀跳不动");
      //     return false;
      // }
      let locationEncode = encodeURIComponent(location);
      axios
        .get("/api/fileDownLoadController/attachmentDownload/" + locationEncode)
        .then(response => {
          //let responseData = response.data;
          console.log(response);
        })
        .catch(error => {
          console.log(error);
          alert("网络错误，不能访问");
        });
    }
  }
};
</script>

<style  scoped>
.CSS5-left {
  float: left;
  border: 1px solid #f00;
}

.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>
